<template>
  <a-modal
    :keyboard="false"
    :title="mainTitle"
    :width="width"
    :visible="visible"
    :destroyOnClose="true"
    @cancel="handleCancel"
    cancelText="关闭"
    class="btn_none">
    <div class="page-header-index-wide">
      <a-card
        :bordered="false"
        :bodyStyle="{ padding: '16px 0', height: '100%' }"
        :style="{ height: '100%' }">
        <a-spin :spinning="confirmLoading">
        <div class="account-settings-info-main" :class="device" :style="'margin-top:-30px;' ">
          <div class="account-settings-info-left">
            <a-menu
              :mode="device == 'mobile' ? 'horizontal' : 'inline'"
              :style="{ border: '0', width: device == 'mobile' ? '560px' : 'auto'}"
              :defaultSelectedKeys="defaultSelectedKeys"
              :selectedKeys="selectedKeys"
              type="inner">
              <a-menu-item key="/account/settings/base" @click="baseInfoClick()">
                {{title}}
              </a-menu-item>
              <a-menu-item v-if="reimbToPlanFormFlag" key="/account/settings/planForm" @click="onPlanClick()">
                事前申请
              </a-menu-item>
              <a-menu-item key="/account/settings/custom" @click="flowChartClick()">
                审批流程
              </a-menu-item>
              <!--绩效数据-->
              <a-menu-item v-if="isOpenPlanPer||isOpenReimbPer"  key="isPlanOrRemib" @click="openPlanOrRemib">
                绩效数据
              </a-menu-item>
              <!--绩效数据-->
              <a-menu-item v-if="isContract"  key="isContract" @click="openContractInfo">
                合同详情
              </a-menu-item>
            </a-menu>
          </div>
          <div class="account-settings-info-right" style="overflow-x: auto">
            <div class="account-settings-info-title">
              <!--合同详情-->
              <div v-if="isContractInfo" style="width: 100%;height: 600px;overflow-y:auto;">
                <a-card style="width: 100%;">
                  <component :is="comps[contractPageName]"  ref="contractModalForm" ></component>
                  <file-upload-in-flow-modal v-show="fileDetailFlag" :tableId="tableId" ref="FileUploadInFlowModal"></file-upload-in-flow-modal>
                </a-card>
              </div>
              <!--申请转报销时显示申请单的框-->
              <div
                v-if="plan"
                style="width: 100%;overflow-y:auto;"
                :style="'min-height:450px;height:'+domHeight+'px' ">
                <a-card style="width: 100%;">
                  <component
                    :is="comps[planPageName]"
                    :title="title.split('·')[1]"
                    ref="modalFormPlan"
                    @back="back"
                    @ok="back"
                    @errback="errback"
                    :isTask="isTask">
                  </component>
                  <!-- 流程控制方式组件 start -->
                  <ProcessNodeControl
                    v-if="branch"
                    :dictItems="dictItems"
                    ref="processNodeControl"
                    @chooseItemRtn="chooseItemRtn">
                  </ProcessNodeControl>
                </a-card>
                <!--流程中上传附件-->
                <file-upload-in-flow-modal
                  v-show="fileFlag || fileDetailFlag"
                  :tableId="tableId"
                  ref="FileUploadInFlowModal">
                </file-upload-in-flow-modal>
              </div>
              <!--审批信息的框-->
              <div
                v-if="approvalInfoFlag"
                style="width: 100%;overflow-y:auto;"
                :style="'min-height:450px;height:'+domHeight+'px' ">
                <opinion :dataSource="dataSource" v-if="getShowOpinion()"></opinion>
                <a-card style="width: 100%;">
                  <component
                    :is="comps[pageName]"
                    :title="title.split('·')[1]"
                    :isTask="isTask"
                    :operate="operate"
                    ref="modalForm"
                    @back="back"
                    @ok="back"
                    @errback="errback">
                  </component>
                  <!-- 流程控制方式组件 start -->
                  <ProcessNodeControl
                    v-if="branch"
                    :dictItems="dictItems"
                    ref="processNodeControl"
                    @chooseItemRtn="chooseItemRtn">
                  </ProcessNodeControl>
                </a-card>
                <!--流程中上传附件-->
                <file-upload-in-flow-modal
                  v-show="fileFlag || fileDetailFlag"
                  :tableId="tableId"
                  ref="FileUploadInFlowModal">
                </file-upload-in-flow-modal>
                <!--流程中确认支付-->
                <confirm-payment-modal
                  v-show="confirmPaymentFlag"
                  :onlyView="onlyView"
                  :reimbId="tableId"
                  @havePayment="havePayment"
                  ref="ConfirmPaymentModal">
                </confirm-payment-modal>
                <!--流程选项-->
                <flow-option-modal
                  v-show="flowOptionFlag"
                  ref="FlowOptionModal"
                  :planId="tableId">
                </flow-option-modal>
                <!--授权委托书-->
                <a-card v-if="printVis" style="width: 100%;margin-top: 5px;">
                  <a-row>
                    <a-form-item
                      :labelCol="labelCol"
                      :wrapperCol="wrapperCol"
                      :label="printName">
                      <a-button @click="handlePrint" type="primary">授权委托书</a-button>
                    </a-form-item>
                  </a-row>
                </a-card>
                <!--借贷信息-->
                <loan-info-in-flow-modal
                  v-show="isLoanShow"
                  :reimbId="tableId"
                  ref="LoanInfoInFlowModal">
                </loan-info-in-flow-modal>
                <div v-if="!onlyView">
                  <!--提交驳回后使用的指定审批人-->
                  <a-card v-if="approverVis" style="width: 100%;margin-top: 5px;">
                    <a-tabs defaultActiveKey="1">
                      <a-tab-pane tab="指定审批人" key="1">
                        <a-row v-if="approverDeptVis">
                          <a-form-item
                            :labelCol="labelCol"
                            :wrapperCol="wrapperCol"
                            label="选择部门">
                            <a-select style="width: 200px" v-model="selectedDept" @change="changePerson">
                              <!-- <a-select-option value="">请选择</a-select-option> -->
                              <a-select-option :value="p.id" v-for="p in deptList">
                                {{p.departName}}
                              </a-select-option>
                            </a-select>
                          </a-form-item>
                        </a-row>
                        <a-row>
                          <a-form-item
                            :labelCol="labelCol"
                            :wrapperCol="wrapperCol"
                            :label="ruleName">
                            <a-select style="width: 200px" v-model="approver">
                              <a-select-option :value="p.id" v-for="p in person">
                                {{p.realname}}
                              </a-select-option>
                            </a-select>
                          </a-form-item>
                        </a-row>
                      </a-tab-pane>
                    </a-tabs>
                  </a-card>
                  <!--驳回和授权委托书提交和编辑合同提交-->
                  <a-card
                    v-if="(editUrl != null && editUrl != '' && editUrl != undefined && editUrl.indexOf('innerpage') == -1) || printVis || !editConInfo || !contractDepts"
                    style="width: 100%;margin-top: 5px;">
                    <a-row style="text-align: center;">
                      <a-button @click="adult(1,true)" type="primary">
                        {{ printVis?'确认':'确认提交' }}
                      </a-button>
                    </a-row>
                  </a-card>
                  <!--传阅-->
                  <a-card v-else-if="editUrl && editUrl.indexOf('chuanyue') > 0" style="width: 100%;margin-top: 5px;">
                    <a-row style="text-align: center;">
                      <a-button @click="circulate()" type="primary">已阅</a-button>
                    </a-row>
                  </a-card>
                  <!--意见信息-->
                  <a-card v-else style="width: 100%;margin-top: 5px;">
                    <a-tabs v-if="!printVis ||editConInfo || contractDepts" defaultActiveKey="1">
                      <a-tab-pane tab="意见信息" key="1">
                        <!--常用意见-->
                        <a-row>
                          <a-form-item
                            :labelCol="labelCol"
                            :wrapperCol="wrapperCol"
                            label="常用意见">
                            <!--同意-->
                            <a-dropdown>
                              <a-menu slot="overlay" @click="chooseContent">
                                <a-menu-item :key="item" v-for="(item,index) in agreeContents">
                                  <a-icon type="highlight"/>
                                  {{item}}
                                </a-menu-item>
                              </a-menu>
                              <a-button type="primary" style="margin-left: 8px">同意
                                <a-icon type="down"/>
                              </a-button>
                            </a-dropdown>
                            <!--不同意-->
                            <a-dropdown>
                              <a-menu slot="overlay" @click="chooseContent">
                                <a-menu-item :key="item" v-for="(item,index) in disagreeContents">
                                  <a-icon type="highlight"/>
                                  {{item}}
                                </a-menu-item>
                              </a-menu>
                              <a-button type="primary" style="margin-left: 8px">不同意
                                <a-icon type="down"/>
                              </a-button>
                            </a-dropdown>
                          </a-form-item>
                        </a-row>
                        <!-- 是否审核结束的选择-只有配置了endTheProcess的innerPage才显示 -->
                        <a-row v-if="endTheProcessFlag">
                          <a-form-item
                            :labelCol="labelCol"
                            :wrapperCol="wrapperCol"
                            :label="endProcessText">
                            <a-switch v-model="endTheProcess" checked-children="是" un-checked-children="否" default-unChecked />
                          </a-form-item>
                        </a-row>
                        <!-- 还款金额的输入框-只有配置了returnMoney的innerPage 且选择了结束流程 才显示 -->
                        <a-row v-if="ifShowReturnFlag && endTheProcess">
                          <a-form-item
                            :labelCol="labelCol"
                            :wrapperCol="wrapperCol"
                            label="还款金额">
                            <a-input type="number" @change="changeReturnMoney" style="width: 20%;margin-right: 10px" v-model="returnMoney" placeholder="请输入还款金额" />
                            剩余待核销总金额：{{waitingMoney}}(元)
                            <a-tag v-if="returnMoneyText" color="red">
                              {{returnMoneyText}}
                            </a-tag>
                          </a-form-item>
                        </a-row>
                        <!-- 审批意见-->
                        <a-row>
                          <a-form-item
                            :labelCol="labelCol"
                            :wrapperCol="wrapperCol"
                            label="审批意见">
                            <a-textarea
                              placeholder="请输入审批意见"
                              v-model="comment"
                              :autosize="{ minRows: 5, maxRows: 8 }">
                            </a-textarea>
                          </a-form-item>
                        </a-row>
                        <!--审批选项-->
                        <a-row style="text-align: center;margin-top: 20px">
                          <a-button
                            v-if="confirmPaymentFlag ? false : refuseFlag" @click="adult(0)"
                            type="danger"
                            style="width: 100px"
                            class="danger">
                            驳回
                          </a-button>
                          <a-button
                            @click="adult(1)"
                            type="primary"
                            style="margin-left: 20px;width: 100px">
                            {{ confirmPaymentFlag ? '支付完成' : '通过' }}
                          </a-button>
                        </a-row>
                      </a-tab-pane>
                    </a-tabs>
                  </a-card>
                </div>
              </div>
              <!--流程图的框-->
              <div v-if="flowChartFlag">
                <a-divider orientation="left">历史流程记录</a-divider>
                <!-- table区域-begin -->
                <div style="margin-top:15px;">
                  <a-table
                    ref="table"
                    size="middle"
                    bordered
                    :columns="columns"
                    :dataSource="dataSource"
                    :pagination="false">
                  </a-table>
                </div>
                <a-divider orientation="left">流程图</a-divider>
                <div>
                  <img :src="imageUrl" @click="(file)=>handlePreview1(file,imageUrl,0)" alt="" style="width: 100%;cursor:pointer"/>
                </div>
              </div>
              <!--绩效组件-->
              <div v-if="perForm">
                <performance-modal ref = "perModal"></performance-modal>
              </div>
            </div>
          </div>
        </div>
        </a-spin>
      </a-card>
      <print-modal v-if="printVis" ref="printModal"></print-modal>
    </div>
    <!-- 经济科目绩效目标查询框 -->
    <expenditure-target-view-modal ref="targetModal" @submitFlow="submitProcess('1')"></expenditure-target-view-modal>
    <!--事后报销变量采集弹窗-->
    <performanceAppraisal-page ref="modalPage" @submitf="submitProcess('2')"></performanceAppraisal-page>
    <!--流程图放大组件-->
    <div class="outer_box"  v-if="previewVisible">
      <previewPicture  :isEdit="false" :isFlow="true" :fileNum="0" @cancel="previewVisible = false" :fileList="previewFileList" ></previewPicture>
    </div>
  </a-modal>
</template>

<script>

  import Vue from 'vue'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import { getAction, postAction, httpAction } from '@/api/manage'
  import PrintModal from '@/views/contract/Signature/PrintModal'
  import PrintTableViewModal from '@/views/reimb/PrintTableViewModal'
  import ProcessNodeControl from '@/views/expenditure/ProcessNodeControl'
  import FileUploadInFlowModal from '@/views/expenditure/modules/FileUploadInFlowModal'
  import ConfirmPaymentModal from '@/views/expenditure/ConfirmPaymentModal'
  import LoanInfoInFlowModal from '@/views/expenditure/modules/LoanInfoInFlowModal'
  import FlowOptionModal from '@/views/expenditure/FlowOptionModal'
  import Opinion from '@/components/page/Opinion'
  import PerformanceModal from '@/components/page/PerformanceModal'
  import ExpenditureTargetViewModal from '@/views/expenditure/modules/ExpenditureTargetViewModal.vue'
  import PerformanceAppraisalPage from '@/views/reimb/PerformanceAppraisalPage'
  import { mixinDevice } from '@/utils/mixin'
  import { getValueByCodeAndText } from '@/api/api'
  import PreviewPicture from '@comp/tools/PreviewPicture'
  export default {
    name: 'TaskDealModal',
    mixins: [JeecgListMixin, mixinDevice],
    components: {
      FlowOptionModal,
      LoanInfoInFlowModal,
      ConfirmPaymentModal,
      PrintModal,
      PrintTableViewModal,
      ProcessNodeControl,
      FileUploadInFlowModal,
      Opinion,
      ExpenditureTargetViewModal,
      PerformanceAppraisalPage,
      PerformanceModal,
      PreviewPicture
    },
    props: {
      //业务主键
      businessKey: String,
      //任务主键
      taskId: String,
      //动态表单页名称
      pageName: String,
      //流程分支标识
      flow: Number,
      //编辑页面url
      editUrl: String,
      //自定义表单
      innerpage: String,
      //内部url
      internalUrl: String
    },
    data () {
      return {
        /*
         * @Author: nhr
         * @Date: 2021-07-14 11:32
         * 重构思路：在不对原有实现存在影响下，对主干的中间页组件进行梳理重构，
         * 梳理所有的页内变量、方法及参数，对部分无用参数or方法删除、名称不规范参数or方法修改、重复用途参数or方法抽取、
         * 删除所有console.log()代码、追加变量or方法注释、重构梳理所有方法的if判断条件，
         * 对变量按照（弹窗基础相关变量、模块or引入组件展示标识、基础常量or待选值列表、业务常量or变量、url）进行分类。
         */
        /** category1. 弹窗基础相关变量 ---start */
        confirmLoading:false, //loading加载状态
        //弹窗展示
        visible: false,
        //弹窗宽度
        width: '',
        //弹窗高度
        domHeight: 800,
        //弹窗名称
        mainTitle: '',
        //当前激活的页签key
        selectedKeys: [],
        //默认激活页签key
        defaultSelectedKeys: [],
        //子组件是否显示滚动条标识
        isTask: 'none',
        //禁用混入组件初始化方法
        disableMixinCreated: true,
        //合同详情
        isContract:false,
        isContractInfo:false,
        //页面布局固定样式
        labelCol: {
          xs: { span: 24 },
          sm: { span: 3 }
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 }
        },
        //表头
        columns: [
          {
            title: '序号',
            dataIndex: '',
            key: 'rowIndex',
            width: 50,
            align: 'center',
            customRender: function (t, r, index) {
              return parseInt(index) + 1
            }
          },
          {
            title: '任务名称',
            align: 'center',
            width: 160,
            dataIndex: 'name',
            ellipsis:true
          },
          {
            title: '处理人',
            align: 'center',
            width: 100,
            dataIndex: 'assigneeName',
            ellipsis:true
          },
          {
            title: '耗时',
            align: 'center',
            width: 120,
            dataIndex: 'duration',
            customRender: function (t, r, index) {
              const duration = r.duration
              let text = ''
              if (duration != null) {
                //计算天数
                let days = Math.floor(duration / (24 * 60 * 60 * 1000))
                if (days != 0) {
                  text += days + '天'
                }
                //计算小时数
                let hourLevel = duration % (24 * 60 * 60 * 1000)
                let hours = Math.floor(hourLevel / (60 * 60 * 1000))
                if (hours != 0) {
                  text += hours + '小时'
                }
                //计算分钟数
                let minutesLevel = hourLevel % (60 * 60 * 1000)
                let minutes = Math.floor(minutesLevel / (60 * 1000))
                if (minutes != 0) {
                  text += minutes + '分'
                }
                //计算秒数
                let seconds = Math.round((minutesLevel % (60 * 1000)) / 1000)
                text += seconds + '秒'
              }
              return text
            }
          },
          {
            title: '开始时间',
            align: 'center',
            width: 160,
            dataIndex: 'startTime'
          },
          {
            title: '结束时间',
            align: 'center',
            width: 160,
            dataIndex: 'endTime'
          },
          {
            title: '审批结果',
            align:"center",
            dataIndex: 'taskFlow',
            width: 80,
            customRender:function (t,r,index) {
              if(t == '1'){
                return '通过'
              }else if(t == '0'){
                return '未通过'
              }
              return t
            }
          },
          {
            title: '审批意见',
            align:"center",
            dataIndex: 'comment'
          }
        ],
        /** ---end */

        /** category2. 模块、引入组件展示标识 ---start*/
        //流程选项组件标识
        flowOptionFlag: false,
        //借贷信息组件标识
        isLoanShow: false,
        //确认支付组件标识
        confirmPaymentFlag: false,
        //上传附件组件标识
        fileFlag: false,
        //流程控制方式组件标识
        branch: false,
        //授权委托书组件标识
        printVis: false,
        //指定审批人模块展示标识
        approverVis: false,
        //审批信息模块展示标识
        approvalInfoFlag: false,
        //申请转报销时申请单模块标识
        plan: false,
        //流程图模块标识
        flowChartFlag: false,
        //事前申请绩效数据框是否展示
        isOpenPlanPer:false,
        //是否报销绩效数据框是否展示
        isOpenReimbPer:false,
        //判断绩效数据是否显示
        perForm:false,
        /** ---end */

        /** category3. 基础常量or待选值列表 ---start */
        //动态组件列表
        comps: [],
        //部门列表
        deptList: [],
        //选中部门
        selectedDept: '',
        //流程控制类型
        dictItems: [],
        //审批人待选列表
        person: [],
        //选中的审批人
        approver: '',
        //同意意见列表
        agreeContents: [],
        //不同意意见列表
        disagreeContents: [],
        //是否显示直接结束流程
        endTheProcessFlag: false,
        //直接结束流程的选项记录
        endTheProcess:false,
        /** ---end */

        /** category4. 业务常量or变量 ---start */
        //流程节点名称
        title: '',
        //各个业务的主键
        tableId: '',
        //合同id
        contractId:'',
        //事前申请的主键
        tablePlanId: '',
        //流程图url
        imageUrl: '',
        //审批意见
        comment: '',
        //角色名称
        ruleName: '',
        //打印授权委托书 字符常量
        printName: '打印授权委托书',
        //详情页文件标识
        fileDetailFlag: false,
        //支出转报销过来的费用标识
        reimbToPlanFormFlag: false,
        //是否已经有支付记录
        isHavePayment: false,
        //审批意见是否必填标识
        approvalRequired: false,
        //流程分支相关
        processBranch: '',
        // TODO 页面只读，后期又出现其它用法，梳理一下，进行区分
        onlyView: false,
        //合同出现确认按钮标识
        contractDepts: true,
        //指定审批人选择部门标识
        approverDeptVis: false,
        // TODO 未知 保留
        disableSubmit: false,
        //具体事项表单的url
        planPageName: '',
        //合同详情url
        contractPageName:'',
        //任务节点的状态 驳回or通过
        flag: 0,
        //支出类型
        expendType: '',
        //合同内容是否可编辑标识
        refuseFlag: true,
        //上会或联签标识
        meetSignatureFlag: true,
        //合同审批子组件详情标识
        childrenProcessDisabled: false,
        //经办人编辑合同
        editConInfo: true,
        //儿童医院流程控制标识
        childProcess: false,
        // 审批意见
        message:'',
        // 核减后的金额
        amount:'',
        // 研究决策
        yjjcText:'',
        // 指定审批人
        approverText:'',
        // 是否三重一大项目
        tripleAndBig:'',
        //提交流程向工作流中传递的对象
        dataObj:null,
        //结束流程节点显示特殊文字
        endProcessText:"审核通过后是否结束流程",
        //是否显示输入还款金额框
        ifShowReturnFlag: false,
        //是否显示输入还款金额框
        returnMoney: 0,
        //剩余待核销金额
        waitingMoney: 0,
        //还钱提示
        returnMoneyText:"",
        //操作类型  do 办理|done 已办
        operate:"do",
        /** ---end */
        url: {
          getContentsByName: '/base/tpApprovalCommonWords/getContentsByName',
          queryExpendById: '/base/tpExpenditureAllocationInfo/queryById',
          getDictItemMsgByDictCodeByAdd: '/sys/dict/getDictItemMsgByDictCodeByAdd',
          queryById: '/base/expenditurePlan/queryById',
          selectBranch: '/base/expenditureBranchRelation/selectBranch',
          queryByReimbId: '/reimb/expenditureReimbInfo/queryById',
          approvalVerification: '/sys/dict/getDictItems',
          getProLeaderUrl: '/budget/budgetSubject/selectProLeaderBySubjectId',
          getSysFileListByMainType: '/expenditure/expenditureOfficeInfo/getSysFileListByMainType',
          queryReport: '/ureport2/ureport2Config/queryReport',
          getUserByRoleName: '/sys/user/getUserByRoleName',
          queryDeptsByRoleName: '/config/config/queryDeptsByRoleName',
          queryAllDepts: '/config/config/queryAllDepts',
          getUsersByRoleNameAndDeptId: '/sys/user/getUsersByRoleNameAndDeptId',
          //删除评价计划
          deleteRecord:'/performance/performanceVariableRecord/deleteRecord',
          //根据主表名称和id查询经济科目
          getInternalId: '/performance/performanceVariableRecord/getInternalId',
          contractInfoById: '/ContractInfo/contractInfo/queryById',
          acceptQueryById:'/contract/contractAcceptance/queryById',
          contractCancelById:'/contract/contractCancel/queryById',
          //根据字典的code和text查询字典的值--开关字典
          getValueByCodeAndText:'/base/controlDict/getValueByCodeAndText',
        },
        //审核通过提示
        auditPassHint: '/sys/dict/getDictItems/audit_pass_hint',
        //通过提示语
        passHint:'',
        //流程图集成放大查看功能
        previewVisible:false,
        previewFileList:[], //图片预览list
      }
    },
    created () {
      // 查询有无预付款配置的停止发票核销特殊文字
      this.getSubsistEndProcess()
      //审批意见是否必填开关
      this.approval()
      //审批意见默认列表
      this.initContents()
      //重置流程中参数
      this.restartDataValue()
      // 查询审核通过提示语
      this.getAuditPassHint()
    },
    mounted () {
      //查询动态组件列表
      this.toUrl()
      //弹窗尺寸自适应
      this.adaptiveSize()

    },
    watch: {
      /**
       * @description 监听结束流程选中的值
       */
      'endTheProcess'(val) {
        this.checkReturnMoney()
      },
    },
    methods: {
      /**
       * @description 查询有无预付款配置的停止发票核销特殊文字
       * @author vinjor-m
       */
      getSubsistEndProcess(){
        getAction(this.url.getValueByCodeAndText,{code:"process_special_code",text:"end_process_subsist"}).then((res)=>{
          //请求成功,且查询出了数据
          if(res.success && res.message){
            this.endProcessText = res.message
          }
        })
      },
      /**
       * @description 检查预付款还钱是否等于待核销的钱
       * @author vinjor-m
       */
      changeReturnMoney(val){
        if(this.returnMoney>this.waitingMoney){
          this.returnMoneyText = "注意：还款金额大于待核销总金额"
        }else if(this.returnMoney<this.waitingMoney){
          this.returnMoneyText = "注意：还款金额小于待核销总金额"
        }else{
          this.returnMoneyText=""
        }
      },
      /**
       * @description 获取预付款待核销总金额
       * @author vinjor-m
       */
      checkReturnMoney(){
        //获取预付款费用待核销总金额
        this.waitingMoney = this.$refs.modalForm.$refs.expenditureSubsistInfoList.waitingMoney
        this.returnMoney=this.waitingMoney
      },
        /**
         * 构建文件路径
         */
        buildPath(invoiceImg) {
          return window._CONFIG['staticDomainURL'] + '/' + invoiceImg
        },
        /**
         * 流程图预览功能集成
         */
        handlePreview1(file,itemlist,index) {
          let data = [];
          data.push({
            originalImage:itemlist,
            name:''
          })
          this.previewFileList.showList =  data

          this.previewVisible = false
          this.previewVisible = true
        },
        /**查询审核通过提示语*/
        async getAuditPassHint(){
          await getAction(this.auditPassHint).then((res)=>{
            //请求成功,且查询出了数据
            if(res.success && res.result.length > 0 && res.result[0].text){
              this.passHint = res.result[0].text
            }else{ //没有配置或者查询失败
              this.passHint = '审核通过'
            }
          })
        },
        //获取是否显示
        getShowOpinion(){
          if(!this.dataSource || this.dataSource.length<2){
              return false
          }
          //驳回的必显示
          if (this.flow ===0 || this.flow ==='0'){
              return true
          }
          let current = this.getNumByDataSource(this.dataSource)
          let lastReject = this.getNumByDataSource(this.getErrorDataSource(this.dataSource))
          return current<=lastReject
        },
        //获取当前在第几个节点
        getNumByDataSource(dataSource){
            let num = 0
            for (let i = 0; i < dataSource.length; i++) {
                if(dataSource[i].taskFlow ){
                    if(dataSource[i].taskFlow === '0'){
                        num=0
                    }else{
                        num++
                    }
                }
            }
            return num+1
        },
        //获取从开始到最后一次驳回的所有节点
        getErrorDataSource(dataSource){
            let data = []
            let ds = dataSource.filter(value => {
                return value.taskFlow && value.taskFlow==='0'
            })
            if(ds && ds.length>0){
                for (let i = 0; i < dataSource.length; i++) {
                    if(dataSource[i].id === ds[ds.length-1].id){
                        data = dataSource.slice(0,i)
                    }
                }
            }
            return data
        },
      /**
       * @description 事前申请回调
       */
      async submitProcess(flag){
        //调用流程流转方法
        await this.commitFLow(this.message, this.amount, this.yjjcText, this.approverText, this.tripleAndBig,this.dataObj).catch(err=>{
          //提交出错
          this.confirmLoading = false
          return false
        })
        //事前申请绩效弹窗
        if ('1'===flag){
          this.$refs.targetModal.visible = false
        } else {
          //事后报销绩效弹窗
          this.$refs.modalPage.visible = false
        }
      },

      /**
       * @description 绩效组件（界面显示）
       */
      openPlanOrRemib(){
        this.plan = false;
        this.approvalInfoFlag = false;
        this.flowChartFlag = false;
        this.perForm = true;
        this.selectedKeys = ["isPlanOrRemib"];
        this.$nextTick(()=>{
          this.$refs.perModal.edit(this.tableId,this.isOpenPlanPer?'expenditure_plan':'expenditure_reimb_info')
        })
      },
      /**
       * @author pqz
       * @description 显示绩效组件（事前申请）
       */
      adultTarget(data){
        this.$nextTick(() => {
          // this.$refs.targetModal.visible = true
          //经济科目id
          this.$refs.targetModal.internalId = data.internalid
          //经济科目名称
          this.$refs.targetModal.internalName =data.internalname
          //数据主表id
          this.$refs.targetModal.mainId = this.tableId
          //调用初始化方法
          this.$refs.targetModal.loadData()
        })
      },
      /**
       * @author pqz
       * @description 显示绩效组件（事后报销变量采集）
       */
      adultRemib(record){
        this.$refs.modalPage.edit(record);
        this.$refs.modalPage.disableSubmit = false;
      },
      /**
       * @description 合同详情组件（界面显示）
       */
      openContractInfo(){
        this.contractPageName='contract/Record/modules/ContractRecordStepByDetailModal'
        this.approvalInfoFlag = false;
        this.flowChartFlag = false;
        this.isContractInfo=true;
        this.selectedKeys = ["isContract"];
        this.$nextTick(()=>{
          this.$refs.contractModalForm.edit(this.contractId);
        })
      },

      /**
       * @author pqz
       * @description 为流程流转参数重置赋值方法
       */
      restartDataValue(){
        this.message = ''
        this.amount = ''
        this.yjjcText = ''
        this.approverText = ''
        this.tripleAndBig = ''
      },
      /**
       * @author pqz
       * @description 为流程流转参数赋值方法（适用于调用绩效组件后的提交）
       */
      setDataValue(message,amount,yjjcText,approverText,tripleAndBig,dataObj){
        this.message = message
        this.amount = amount
        this.yjjcText = yjjcText
        this.approverText = approverText
        this.tripleAndBig = tripleAndBig
        this.dataObj = dataObj
      },

      /**
       * @author pqz
       * @description 判断是支出绩效提示还是报销绩效提示
       */
      async checkPlanOrRemib() {
        if (this.isOpenPlanPer) {
          await getAction(this.url.queryById, { id: this.tableId }).then((res) => {
            if (res.success) {
              this.adultTarget(res.result)
            }
          })
        } else if (this.isOpenReimbPer) {
          await getAction(this.url.queryByReimbId, { id: this.tableId }).then((res) => {
            if (res.success) {
              let record = {
                internalId: res.result.internalid,
                tableId: res.result.id
              }
              this.adultRemib(record)
            }
          })
        }
      },
      /**获取审批通过是否必填数据字典开关配置*/
      approval () {
        getValueByCodeAndText({ code: 'approval_verification', text: 'state' }).then(res => {
          if (res.success && res.message) {
            if (res.message === '1') {
              this.approvalRequired = true
            }else {
              this.approvalRequired = false
            }
          }else{
            this.approvalRequired = false
          }
        })
      },
      /**自适应弹窗高度or宽度*/
      adaptiveSize () {
        let that = this
        this.width = window.innerWidth
        //获取浏览器可视区域高度
        this.domHeight = `${document.documentElement.clientHeight}` - 320
        //浏览器被重置大小时，重新获取浏览器的可视区域高度
        window.onresize = function () {
          that.domHeight = `${document.documentElement.clientHeight}` - 320
        }
      },
      /**申请转报销费用的事前申请页签点击事件*/
      onPlanClick () {
        this.perForm = false
        //展示申请转报销的申请单
        this.plan = true
        //不展示审批信息
        this.approvalInfoFlag = false
        //不展示流程图
        this.flowChartFlag = false
        this.selectedKeys = ['/account/settings/planForm']
        this.$nextTick(() => {
          this.fileDetailFlag = false
          //根据mainId查询附件列表
          getAction(this.url.getSysFileListByMainType, { mainId: this.tablePlanId }).then(res => {
            if (res.success) {
              //文件或图片列表不为空
              if (res.result.review.length > 0 || res.result.reviewImage.length > 0) {
                let flag = 'file'
                if (res.result.review.length > 0 && res.result.reviewImage.length > 0) {
                  flag = 'all'
                } else if (res.result.reviewImage.length > 0) {
                  flag = 'img'
                }
                this.fileDetailFlag = true
                this.$refs.FileUploadInFlowModal.disabled = true
                this.$refs.FileUploadInFlowModal.getData(this.tablePlanId, flag)
              } else {
                //文件和图片列表都为空
                this.fileDetailFlag = false
              }
            } else {
              this.$message.error('查询附件列表时发生错误！')
            }
          })
          this.$refs.modalFormPlan.expendtype = this.expendType
          this.$refs.modalFormPlan.detailFlag = true
          this.$refs.modalFormPlan.edit(this.tablePlanId)
        })
      },
      /**确认支付功能回调函数，返回是否已经有支付记录*/
      havePayment (flag) {
        this.isHavePayment = flag
      },
      /**流程分支组件回调方法*/
      chooseItemRtn (rtn) {
        this.processBranch = rtn
      },
      /**授权委托书*/
      handlePrint () {
        let param = {
          flag: 'other',
          formType: 'contract_power_of_attorney_other'
        }
        //查询动态报表授权委托书配置
        getAction(this.url.queryReport, param).then(res => {
          if (res.success) {
            if (res.result && res.result.formTypeName) {
              //存在配置
              let reportName = res.result.formTypeName
              let sourceName = Vue.ls.get('SOURCE_NAME')
              //如果sourceName为空 默认为master
              if (!sourceName || sourceName === '') {
                sourceName = 'master'
              }
              //如果配置了报表头部按钮，则用配置的，否则就不显示头部工具栏
              let url = process.env.VUE_APP_URL + '/ureport/preview?_u=' + sourceName + 'db:' + reportName + '&id=' + this.$refs.modalForm.id + '&_t=' + res.result.reportHeaderButton + '&_n=授权委托书'
              this.$refs.printModal.showUrl(this.$refs.modalForm.id, url)
            } else {
              //未配置 执行旧版
              this.$refs.printModal.show(this.$refs.modalForm.id)
            }
          } else {
            this.$message.error('查询动态报表授权委托书配置时发生错误！')
          }
        })
      },
      /**根据角色名查询所有用户*/
      getPersons (roleName) {
        if (roleName && roleName != '') {
          //角色名称不为空，执行查询
          getAction(this.url.getUserByRoleName, { roleName: this.ruleName }).then(res => {
            if (res.success) {
              this.person = res.result
            } else {
              this.$message.error('查询所属角色用户列表时发生错误！')
            }
          })
        }
      },
      /**根据角色名获取部门*/
      getDeptList (roleName) {
        //执行查询
        getAction(this.url.queryDeptsByRoleName, { roleName: roleName }).then(res => {
          if (res.success) {
            this.deptList = res.result
          } else {
            this.$message.error('获取角色的部门列表时发生错误！')
          }
        })
      },
      /**查询全部部门信息*/
      getAllDeptList () {
        getAction(this.url.queryAllDepts, {}).then(res => {
          if (res.success) {
            this.deptList = res.result
          } else {
            this.$message.error('查询所有部门信息时发生错误！')
          }
        })
      },
      /**根据角色名称与部门id查询用户*/
      changePerson (deptId) {
        getAction(this.url.getUsersByRoleNameAndDeptId, { roleName: this.ruleName, deptId: deptId }).then(res => {
          if (res.success) {
            this.person = res.result
            this.approver = ''
          } else {
            this.$message.error('获取用户信息时发生错误！')
          }
        })
      },
      /**处理成功回调*/
      back () {
        this.$emit('ok')
        this.confirmLoading = false
        this.$refs.modalForm.confirmLoading = false
      },
      /**处理失败回调*/
      errback () {
        this.confirmLoading = false
        this.$refs.modalForm.confirmLoading = false
      },
      /**选择常用意见*/
      chooseContent (e) {
        this.comment = e.key
      },
      /**查询常用意见语*/
      initContents () {
        //查询预设意见列表
        getAction(this.url.getContentsByName, {}).then(res => {
          if (res.success) {
            this.agreeContents = res.result.agree
            this.disagreeContents = res.result.disagree
          } else {
            this.$message.error('查询常用意见语时发生错误！')
          }
        })
      },
      /**初始化  operate:do 办理|done 已办*/
      async initData (id, title, record,operate) {
        this.visible = true
        this.operate = operate
        this.comment = ''
        this.title = title
        this.mainTitle = '审批流程（' + this.title + '）'
        this.defaultSelectedKeys = ['/account/settings/base']
        this.tableId = id
        this.businessId = id
        this.reimbToPlanFormFlag = false
        this.approvalInfoFlag = true
        this.flowChartFlag = false
        this.approverDeptVis = false
        this.contractDepts = true
        this.childProcess = false
        this.isContract = false
        this.isContractInfo = false

        this.parem = {
          expendtype: '',
          dataId: id
        }
        /** 此方法注释,原因:在下方方法中有重复调用*/
        // this.$nextTick(() => {
        //   //页面加载完毕后 初始化动态表单
        //   this.$refs.modalForm.edit(id)
        // })
        //初始化设置
        this.baseInfoClick()
      },
      /**初始化所有部门传递给子组件*/
      initAllDepts () {
        getAction('/sys/sysDepart/getDeptList').then(deptRes => {
          if (deptRes.success) {
            let depList = []
            for (let i = 0; i < deptRes.result.length; i++) {
              let data = {
                id: deptRes.result[i].id,
                key: deptRes.result[i].id,
                value: deptRes.result[i].id,
                applydeptid: deptRes.result[i].id,
                title: deptRes.result[i].departName,
                text: deptRes.result[i].departName,
                applydeptname: deptRes.result[i].departName
              }
              depList.push(data)
            }
            this.$refs.modalForm.deptList = depList
          }
        })
      },
      /**根据支出事项配置的流程分支类型进行查询*/
      branchByList () {
        this.$nextTick(() => {
          getAction(this.url.queryExpendById, { id: this.expendType }).then(res => {
            //查询成功且流程配置了流程分支数据
            if (res.success && res.result.processBranchControl && res.result.processBranchControl != '') {
              //查询数据流程分支配置的数据
              getAction(this.url.getDictItemMsgByDictCodeByAdd, { dictCode: res.result.processBranchControl }).then(res1 => {
                if (res1.result.length > 0) {
                  //如果能查询相应的数据时，则展示流程控制组件，否则隐藏（默认隐藏）
                  let dictList = []
                  for (let i = 0; i < res1.result.length; i++) {
                    let list = res1.result[i].descriptions.split(',')
                    dictList.push(list)
                  }
                  this.$nextTick(() => {
                    for (let i = 0; i < res1.result.length; i++) {
                      res1.result[i].dictCode1 = ''
                    }
                    //调用ProcessNodeControl组件的dicts方法,给点选按钮初始化数据
                    this.$refs.processNodeControl.dicts(res1.result)
                    //如果经办人开始时选择了上会或者联签,给单选按钮赋值
                    if (this.parem.dataId && this.parem.dataId != '') {
                      postAction(this.url.selectBranch, this.parem).then(res => {
                        if (res.success) {
                          this.$nextTick(() => {
                            this.$refs.processNodeControl.processBranchs(res.result)
                          })
                        }
                      })
                    }
                  })
                }
              })
            }
          })
        })
      },
      /**上会联签*/
      otherBranchList () {
        getAction(this.url.getDictItemMsgByDictCodeByAdd, { dictCode: 'attend_meet_signature' }).then(res1 => {
          if (res1.result.length > 0) {
            let dictList = []
            for (let i = 0; i < res1.result.length; i++) {
              let list = res1.result[i].descriptions.split(',')
              dictList.push(list)
            }
            this.$nextTick(() => {
              for (let i = 0; i < res1.result.length; i++) {
                res1.result[i].dictCode1 = ''
              }
              //调用ProcessNodeControl组件的dicts方法,给点选按钮初始化数据
              this.$refs.processNodeControl.dicts(res1.result)
              //如果经办人开始时选择了上会或者联签,给单选按钮赋值
              if (this.parem.dataId != undefined && this.parem.dataId != '' && this.parem.dataId != null) {
                postAction(this.url.selectBranch, this.parem).then(res => {
                  if (res.success) {
                    this.$nextTick(() => {
                      this.$refs.processNodeControl.processBranchs(res.result)
                    })
                  }
                })
              }
            })
          }
        })
      },
      /**查询支出事项配置*/
      initAllocationInfo (expendtype) {
        this.approverVis = false
        this.approverDeptVis = false
        getAction(this.url.queryExpendById, { id: expendtype }).then(res => {
          if (res.success) {
            if (res.result && res.result.isApprover && res.result.isApprover != '') {
              this.ruleName = res.result.isApprover
              this.approverVis = true
              //根据角色名查询所有用户
              this.getPersons(this.ruleName)
            }
          }
        })
      },
      /**获取动态组件URL*/
      toUrl () {
        let resultComps = {}
        //在views目录下查找 and 遍历子文件夹 and 正则匹配以 .vue结尾的文件
        let requireComponent = require.context('../../views/', true, /\.vue$/)
        requireComponent.keys().forEach(fileName => {
          let comp = requireComponent(fileName)
          resultComps[fileName.replace(/^\.\/(.*)\.\w+$/, '$1')] = comp.default
        })
        this.comps = resultComps
      },
      /**关闭*/
      close () {
        this.confirmLoading = false
        this.visible = false
        this.approverVis = false
        this.refuseFlag = true
        this.deptList = []
        this.approver = ''
        this.ruleName = ''
        this.selectedDept = ''
        this.meetSignatureFlag = true
        this.$refs.modalForm.detailFlag = true
        this.endTheProcessFlag = false
        this.ifShowReturnFlag = false
        this.returnMoney = 0
        this.endTheProcess = false
      },
      /**取消*/
      handleCancel () {
        this.close()
        this.$refs.modalForm.close()
      },
      /**基础信息页签点击事件*/
      baseInfoClick () {
        this.isLoanShow = false
        this.plan = false
        this.isHavePayment = false
        this.fileFlag = false
        this.approvalInfoFlag = true
        this.flowChartFlag = false
        this.approverVis = false
        this.printVis = false
        this.perForm = false;
        this.isContractInfo = false
        this.selectedKeys = ['/account/settings/base']
        this.$nextTick(async () => {
          //查询审批记录
          this.loadList()
          //填写零余额、基本户、库存金额的借贷信息
          if (this.innerpage && (this.innerpage.indexOf('loanInfo') !== -1 || this.innerpage.indexOf('loanInfoDetail') !== -1)) {
            this.isLoanShow = true
            if (this.innerpage.indexOf('loanInfoDetail') !== -1) {
              this.$refs.LoanInfoInFlowModal.initData(true)
            } else {
              this.$refs.LoanInfoInFlowModal.initData(false)
            }
          } else {
            this.isLoanShow = false
          }
          //流程选项
          if (this.innerpage && this.innerpage.indexOf('FlowOptionModal') !== -1) {
            this.flowOptionFlag = true
            let flag = ''
            if (this.innerpage.indexOf('FlowOptionModal[') !== -1) {
              flag = this.innerpage.substring(this.innerpage.indexOf('FlowOptionModal[') + 16, this.innerpage.indexOf(']'))
            }
            this.$refs.FlowOptionModal.initData(this.tableId, flag)
          } else {
            this.flowOptionFlag = false
          }
          //如果配置了endTheProcess，则显示是否直接审核结束的选择框
          if (this.innerpage && this.innerpage.indexOf('endTheProcess') != -1) {
            this.endTheProcessFlag = true
          }
          //如果配置了returnMoney，则显示输入还款金额框
          if (this.innerpage && this.innerpage.indexOf('returnMoney') != -1) {
            this.ifShowReturnFlag = true
          }
          //合同审计
          if (this.innerpage && this.innerpage.indexOf('contractAudit') != -1) {
            this.$refs.modalForm.isAudit = true
          }
          //出纳确认支付
          if (this.innerpage && this.innerpage.indexOf('confirmPayment') != -1) {
            this.confirmPaymentFlag = true
            this.$refs.ConfirmPaymentModal.initData(this.tableId)
          } else {
            this.confirmPaymentFlag = false
          }
          //采购需求在指定节点可以对 组织形式 进行修改，且必填
          if (this.innerpage && this.innerpage.indexOf('purchaseChooseWay') != -1) {
            this.$refs.modalForm.canChoosePurchaseWay = true
          }
          //采购需求在指定节点可以对 采购归口部门 进行修改，且必填
          if (this.innerpage && this.innerpage.indexOf('demandResponsible') != -1) {
            this.$refs.modalForm.departSelectSite = true
          }
          if(this.innerpage && this.innerpage.indexOf('canChangeMoney')!=-1){//采购审核可更改金额和数量
            this.$refs.modalForm.canChangeMoney=true
          }
          //填写用章归还时间是否可编辑
          if (this.innerpage && this.innerpage.indexOf('SealBackTime') != -1) {
            this.$refs.modalForm.changeEditGivebackDate(false)
          }
          //差旅费明细可修改
          if (this.innerpage && this.innerpage.indexOf('traveDetailEdit') != -1) {
            this.$refs.modalForm.traveDetailEdit = true
          }
          //财务可选择预算
          if (this.innerpage && this.innerpage.indexOf('budgetinformationmodal') != -1) {
            this.$refs.modalForm.budgetFlag = true
          }
          //公务用车-司机(可编辑)公务用车-车牌号(可编辑) （已办页面不可编辑）
          if (!this.onlyView && this.innerpage && this.innerpage.indexOf('carDriver') != -1 && this.innerpage.indexOf('carLicense') != -1) {
            this.$refs.modalForm.DriverLicenseShow = true
          }
          //财务可选预算类型
          if(this.innerpage && this.innerpage.indexOf('budgetTypeSelect')!==-1){ //财务可选择预算类型
            this.$refs.modalForm.detailFlag = false;
          }
          //合同签审审核到确认备案的节点，可以上传图片
          if (this.innerpage && this.innerpage.indexOf('confirmContractRecord') != -1) {
            this.$refs.modalForm.isConfirmContractRecord = true
          }
          //合同签审审核可以修改合同档案编号
          if(this.innerpage&&this.innerpage.indexOf('contractRecordNumber')!=-1){
            this.$refs.modalForm.contractRecordNumber=false
          }
          //拟定合同审核是否可以编辑个人合同
          if (this.innerpage && this.innerpage.indexOf('draftContractEdit') != -1) {
            this.$refs.modalForm.draftContractEdit = true
          }
          //拟定合同审核是否可以批注个人合同
          if (this.innerpage && this.innerpage.indexOf('draftContractComment') != -1) {
            this.$refs.modalForm.draftContractComment = true
          }
          //仅会计人员能维护伙食补助和交通补助
          if (this.innerpage && this.innerpage.indexOf('hsfeesnfee') !== -1) {
            this.$refs.modalForm.standardFlag = true
          }
          //物资入库编辑入库时间
          if (this.innerpage && this.innerpage.indexOf('inDate') !== -1) {
            this.$refs.modalForm.inDateFlag = false
          }
          //物资入库状态
          if (this.innerpage && this.innerpage.indexOf('checkState') !== -1) {
            this.$refs.modalForm.checkStateFlag = false
          }

          //审核过程中上传附件
          if (this.innerpage && this.innerpage.indexOf('FileUploadReviewModal') != -1) {
            this.fileFlag = true
            let flag = 'file'
            if (this.innerpage.indexOf('|') !== -1) {
              flag = this.innerpage.substring(this.innerpage.indexOf('|') + 1, this.innerpage.length)
            }

            this.$refs.FileUploadInFlowModal.disabled = false
            this.$refs.FileUploadInFlowModal.getData(this.tableId, flag)
          }
          //审核过程中 不开启 上传附件组件时，若有附件，只查看
          if (!this.innerpage || this.innerpage.indexOf('FileUploadReviewModal') === -1) {
            //查询附件上传有没有文件，有文件则显示上传附件组件，并且disabled
            getAction(this.url.getSysFileListByMainType, { mainId: this.tableId }).then(res => {
              if (res.success && (res.result.review.length > 0 || res.result.reviewImage.length > 0)) {
                let flag = 'file'
                if (res.result.review.length > 0 && res.result.reviewImage.length > 0) {
                  flag = 'all'
                } else if (res.result.reviewImage.length > 0) {
                  flag = 'img'
                }
                this.fileDetailFlag = true
                this.$refs.FileUploadInFlowModal.disabled = true
                this.$refs.FileUploadInFlowModal.getData(this.tableId, flag)
              } else {
                this.fileDetailFlag = false
              }
            })
          }
          if (this.innerpage && this.innerpage.indexOf('accountbilledit') != -1) {
            this.$refs.modalForm.accountbillFlag = false
          }
          //上会联签
          if (this.innerpage && this.innerpage.indexOf('yjjc') != -1) {
            this.branch = true
            this.branch = this.meetSignatureFlag
          }
          //非支出和报销流程的上会联签（如采购或者合同）
          if (this.innerpage && this.innerpage.indexOf('yjjcothers') != -1) {
            this.branch = true
            this.otherBranchList()
            this.branch = this.meetSignatureFlag
          }
          //核减金额
          if (this.innerpage && this.innerpage.indexOf('reduction') != -1) {
            this.$refs.modalForm.reductionFlag = true
          }
          //授权委托书
          if (this.innerpage && this.innerpage.indexOf('sqwts') != -1) {
            this.printVis = true
          }
          //回执单渲染  2021年4月8日 17:45 胡帅 (已办页面不可编辑)
          if (!this.onlyView && this.innerpage && this.innerpage.indexOf('receipt') != -1) {
            this.$refs.modalForm.receiptShow = false
          }
          //指定审批人
          if (this.innerpage && this.innerpage.indexOf('zdspr') != -1) {
            this.approverVis = true
            this.ruleName = this.innerpage.substring(this.innerpage.indexOf('|') + 1, this.innerpage.length)
            //指定审批人部门
            if (this.innerpage.indexOf('zdsprdept') != -1) {
              this.approverDeptVis = true
              //查询所有部门
              this.getDeptList(this.ruleName)
            } else {
              this.getPersons(this.ruleName)
            }
          }
          //儿童医院合同流程控制组件
          if (this.innerpage && this.innerpage.indexOf('childProcess') != -1) {
            this.$refs.modalForm.childProcess = true
            let flag = this.innerpage.substring(this.innerpage.indexOf('|') + 1, this.innerpage.length)
            this.$refs.modalForm.childProcess = true
            this.$refs.modalForm.initProcess(flag)
            this.childProcess = true
          }
          //儿童医院编辑合同内容
          if (this.innerpage && this.innerpage.indexOf('editContract') != -1) {
            this.$refs.modalForm.isDisabled = false
            this.editConInfo = false
            this.$refs.modalForm.disabledEdit()
          }
          //审批不允许驳回
          if(this.innerpage && this.innerpage.indexOf('refuse')!==-1){
            this.refuseFlag = false
          }
          //消防总队采购结果录入指定生成合同部门
          if (this.innerpage && this.innerpage.indexOf('appointContractDep') != -1) {
            //是否合同新增页面，如果是，则目标页面内嵌合同新增页面
            this.$refs.modalForm.isContractRecord = false
            //出现指定审批人页面
            this.approverVis = true
            //选择部门
            this.approverDeptVis = true
            //出现确认按钮
            this.contractDepts = false
            //获取角色信息（部门负责人）
            this.ruleName = this.innerpage.substring(this.innerpage.indexOf('|') + 1, this.innerpage.length)
            this.getAllDeptList()
          }
          //消防总队采购编辑合同
          if (this.innerpage && this.innerpage.indexOf('purchaseEditContract') != -1) {
            //展示合同编辑页面
            this.editConInfo = false
            this.$refs.modalForm.isContractRecord = true
            this.$refs.modalForm.disabledEdit(this.tableId, this.onlyView)
          }
          this.$refs.modalForm.expendtype = this.expendType
          this.$refs.modalForm.edit(this.tableId)
          //查询申请主表
          getAction(this.url.queryById, { id: this.tableId }).then(res => {
            if (res.result) {
              this.expendType = res.result.expendtype
              this.branchByList()
              this.$refs.modalForm.expendtype = this.expendType
              if (this.editUrl != null && this.editUrl !== '' && this.editUrl !== undefined && this.editUrl.indexOf('innerpage') === -1) {
                this.initAllocationInfo(this.expendType)
              }
            } else {
              //结果集为空 查询报销主表
              getAction(this.url.queryByReimbId, { id: this.tableId }).then(res => {
                this.expendType = res.result.expendtype
                this.branchByList()
                //是否是支出转报销
                if (res.result.planid && res.result.planid !== '') {
                  this.reimbToPlanFormFlag = true
                  this.tablePlanId = res.result.planid
                  this.planPageName = res.result.detailRouting
                } else {
                  this.reimbToPlanFormFlag = false
                }
                //支出类型
                this.$refs.modalForm.expendtype = this.expendType
                if (this.editUrl && this.editUrl !== '' && this.editUrl.indexOf('innerpage') === -1) {
                  //查询支出事项配置
                  this.initAllocationInfo(this.expendType)
                }
              }).finally(() => {
                //报销编辑所有信息时，预算是否必填
                if (this.innerpage && this.innerpage.indexOf('budgetinformationmodal') !== -1 && this.innerpage.indexOf('editAll') !== -1) {
                  this.$refs.modalForm.budgetShowType = '1'
                  this.$refs.modalForm.budgetRequiredType = '1'
                }
                //配置了财务选预算时，预算显示
                if (this.innerpage && this.innerpage.indexOf('budgetinformationmodal') !== -1) {
                  this.$refs.modalForm.budgetShowType = '1'
                }
                //报销编辑所有信息时，初始化部门为所有部门
                if (this.innerpage && this.innerpage.indexOf('editAll') !== -1) {
                  this.initAllDepts()
                }
              }).catch(()=>{
                //为了适配非支出或报销费用查看
              })
            }
          })
          //查询合同验收申请
          getAction(this.url.acceptQueryById,{id:this.tableId}).then(res=>{
            if (res.result){
              this.contractId = res.result.contractId
              this.isContract = true
            }
          })
          //查询合同作废申请
          getAction(this.url.contractCancelById,{id:this.tableId}).then(res=>{
            if (res.result){
              this.contractId = res.result.contractId
              this.isContract = true
            }
          })

        })
      },
      /**流程图页签点击事件*/
      flowChartClick () {
        this.perForm = false;
        this.plan = false
        this.approvalInfoFlag = false
        this.flowChartFlag = true
        this.isContractInfo = false
        this.selectedKeys = ['/account/settings/custom']
        this.loadList()
        //查询流程图
        getAction('/handle/getPic/' + this.businessKey, {}).then((res) => {
          this.imageUrl = 'data:image/png;base64,' + res
        })
      },
      /**获取审批历史记录*/
      async loadList () {
        this.loading = true
        await getAction('/act/taskinst/history/task/' + this.businessKey, {}).then((res) => {
          if (res.success) {
            this.dataSource = res.result
            this.$nextTick(() => {
              this.$refs.FlowOptionModal.getVariablesByExecutionId(res.result[0].procInstId)
            })
          } else {
            this.$message.error('查询审批历史记录发生错误！')
          }
        }).finally(() => {
          this.loading = false
        })
      },
      /**传阅点击事件*/
      circulate () {
        this.comment = '传阅完毕'
        this.adult(1)
      },

      /**
       * 驳回、通过、确认提交操作
       * @param resultFlat 0驳回 1通过
       * @param isReject boolean 是否审批意见必填
       * modify by     date         description
       * vinjor-m     2021-9-16   逻辑重构，1.驳回，直接调提交方法；
       * 2.通过，editUrl配置了，含innerpage，调handleOk，再调提交；重新选择预算、核减预算都需要单独做绩效的相关处理
       * 未配置或配置的不含innerpage，直接提交
       */
      async adult (resultFlat, isReject) {
        //页面加载中状态
        this.confirmLoading = true
        if(this.businessKey.indexOf("expenditure_subsist_virtual.expenditure_subsist_virtual")!==-1 && 1===resultFlat){
          //预付款发票核销子流程被驳回后，再次提交，需要调用一下子组件保存核销发票明细方法
          let subsistResult = await this.$refs.modalForm.submitSubsistDetail(this.tableId).catch(()=>{
            return false
          })
          if (subsistResult === 0 || subsistResult === false) {
            this.confirmLoading = false
            return false
          }
        }
        //流程选项
        if (this.flowOptionFlag) {
          let flowOptionResult = await this.$refs.FlowOptionModal.check()
          if (!flowOptionResult) {
            this.confirmLoading = false
            return false
          }
        }
        //审批通过时保存授权委托书
        if (this.printVis && (resultFlat === 1 || resultFlat === '1' || resultFlat === 2 || resultFlat === '2')) {
          this.$refs.printModal.save(this.$refs.modalForm.id)
        }
        //出纳确认支付功能，若开启，调用getPaymentOk方法确认支付完成，若未完成支付，流程不可通过
        if (this.confirmPaymentFlag && (resultFlat === '1' || resultFlat === 1)) {
          let payResult = await this.$refs.ConfirmPaymentModal.getPaymentOk(this.tableId)
          if (payResult === 0) {
            this.confirmLoading = false
            return false
          }
        }
        //填写借贷信息功能,若开启，调用handleOk方法保存借贷信息
        if (this.isLoanShow && (resultFlat === '1' || resultFlat === 1)) {
          let loanResult = await this.$refs.LoanInfoInFlowModal.handleOk()
          if (loanResult === 0 || loanResult === false) {
            this.confirmLoading = false
            return false
          }
        }
        //编辑全部内容时，又配置了预算必填，编辑页的预算必填与审核过程中预算必填冲突，所以放在这里验证
        if (this.innerpage && this.innerpage.indexOf('budgetinformationmodal') !== -1 && this.innerpage.indexOf('editAll') !== -1) {
          if (!this.$refs.modalForm.$refs.budgetinformationmodal || !this.$refs.modalForm.$refs.budgetinformationmodal.budgetModel || !this.$refs.modalForm.$refs.budgetinformationmodal.budgetModel.id || '' === this.$refs.modalForm.$refs.budgetinformationmodal.budgetModel.id) {
            this.$message.info('请选择预算信息')
            this.confirmLoading = false
            return false
          }
        }
        //研究决策
        let yjjcText = '0'
        // 添加this.processBranch.length>0 是为了解决下面在没有值时拿数据报错问题
        if (this.branch && this.processBranch.length>0) {
          let arr = this.processBranch[0].dictCode1
          yjjcText = arr.split(',')[1]
        }
        //指定审批人
        let approverText = '0'
        if (this.approverVis && (resultFlat == 1 || resultFlat == 2)) {
          if (this.approverDeptVis) {
            if (!this.selectedDept || !this.approver || '' === this.approver) {
              this.$message.warning('请选择审批人')
              this.confirmLoading = false
              return
            }
            //消防总队审核页面
            if (this.innerpage.indexOf('appointContractDep') != -1) {
              approverText = this.approver
            } else {
              approverText = this.approver + ',' + this.selectedDept
            }
          } else {
            if (!this.approver || '' === this.approver) {
              this.$message.warning('请选择审批人')
              this.confirmLoading = false
              return
            }
            approverText = this.approver
          }
        }
        this.flag = resultFlat
        if (this.flag === 0 || this.flag === '0') {
          //驳回必须输入意见
          if (this.comment == null || this.comment == '' || this.comment == undefined) {
            this.$message.warning('请填写审批意见')
            this.confirmLoading = false
            return
          }
        }
        //审批通过时,审批通过内容是否必填
        if (!isReject && this.flag === 1 || this.flag === '1') {
          //01必填,02不必填
          if (this.approvalRequired) {
            if (this.comment == null || this.comment == '' || this.comment == undefined) {
              this.$message.warning('请填写审批意见')
              this.confirmLoading = false
              return false
            }
          }
        }
        if (this.printVis) {
          this.$refs.printModal.save(this.$refs.modalForm.id)
        }
        //审批通过时，调用流程中上传文件的保存
        if ((resultFlat === 1 || resultFlat === '1') && this.fileFlag) {
          let fileOk = true
          await this.$refs.FileUploadInFlowModal.handleOk().catch(err=>{
            fileOk = false
          })
          if (!fileOk) {
            this.confirmLoading = false
            return false
          }
        }
        //儿童医院合同流程
        let tripleAndBig = '0'
        //是否三重一大项目
        if (this.childProcess) {
          await getAction(this.url.contractInfoById, { id: this.tableId }).then((res) => {
            if (res.success) {
              let otherFields = JSON.parse(res.result.otherFields)
              tripleAndBig = otherFields ? otherFields.tripleBig : '0'
            }
          })
          let childProcessResult = true
          await this.$refs.modalForm.contractPro(resultFlat).catch(err=>{
            childProcessResult=false
          })
          if (!childProcessResult) {
            this.confirmLoading = false
            return false
          }
        }
        let amount = 0
        //审批意见因为输入/会报错，所以先用URL编码，再用BASE64编码传给后台，再由后台解码
        let message = btoa(encodeURIComponent(this.comment))
        if (message == null || message == '' || message == undefined || message.split(' ').join('').length == 0) {
          message = btoa(encodeURIComponent(this.passHint))
        }
        if (this.flag == '0') {
          //如果是驳回的情况，驳回除了判断审批意见必填外，无需调用handleOk，直接进行工作流驳回处理
          //如果开启了绩效开关，驳回时删除相应的采集数据
          if (this.isOpenPlanPer || this.isOpenReimbPer){
            getAction(this.url.deleteRecord,{mainId:this.tableId})
          }
          if (this.$refs.modalForm.amount) {
            amount = this.$refs.modalForm.amount
          }
          let resultFlag = true
          await this.commitFLow(message, amount, yjjcText, approverText, tripleAndBig, null).catch(err=>{
            resultFlag = false
          })
          if(!resultFlag){
            this.confirmLoading = false
            return false
          }
        } else {
          /** refactor start  ------vinjor-m */
          //提交的参数，默认是null，如果需要赋值，在以下方法中赋值即可
          let dataObj =null
          //默认不需要处理绩效的情况
          let checkPerformance = false
          //默认都需要执行handleOk方法
          let ifDoHandleOk = true
          //如果是通过的情况
          if (this.editUrl && this.editUrl.indexOf('innerpage') === -1) {
            //配置了自定义表单，但是不是配置的innerpage，代表是驳回后编辑，需要走handleOk
            //没有配置的innerpage（经办人填报）
            this.comment = "编辑完毕"
            this.flag = "1"
          } else if (this.editUrl && this.editUrl.indexOf('innerpage') !== -1) {
            //配置了自定义表单，并且也匹配到了innerpage，代表需要编辑某些数据，需要调handleOk并提交
            //判断是否是财务选择预算
            if (this.editUrl.indexOf('budgetinformationmodal') !== -1 ){
              //配置了财务选择预算，如果预算改变了，需要处理绩效相关数据
              this.comment = "编辑完毕"
              this.flag = "1"
              if (this.isOpenPlanPer || this.isOpenReimbPer) {
                let table = ''
                if (this.isOpenPlanPer) {
                  table = 'expenditure_plan'
                } else if (this.isOpenReimbPer) {
                  table = 'expenditure_reimb_info'
                }
                let params = { mainId: this.tableId, dataTable: table }
                await getAction(this.url.getInternalId, params).then(async (res) => {
                  if (this.$refs.modalForm.$refs.budgetinformationmodal.getBudgetInfoForPrimaryTable().id !== res.result) {
                    //预算改变了，需要处理绩效
                    checkPerformance = true
                  }
                })
              }
              //财务节点是否开启了流程选项
              if (this.flowOptionFlag) {
                dataObj={}
                Object.assign(dataObj,this.$refs.FlowOptionModal.getData())
              }
            }else if(this.editUrl.indexOf('reduction') !== -1 ){
              //核减预算
              if (this.isOpenPlanPer || this.isOpenReimbPer ) {
                //开了绩效
                if (this.$refs.modalForm.reductionAmount && this.$refs.modalForm.reductionAmount.length > 0) {
                  //核减金额不为空，需要处理绩效
                  checkPerformance = true
                }
              }
            }else if(this.innerpage && this.innerpage.indexOf('FileUploadReviewModal') !== -1) {
              //0706添加 如果是添加附件的innerpage 就不需要走详情页面的保存了
              ifDoHandleOk=false
            } else {
              //其他情况
              let purchaseWay = this.$refs.modalForm.model ? this.$refs.modalForm.model.purchaseway : ''
              dataObj = {
                purchaseWay: purchaseWay
              }
              //是否开启了流程选项
              if (this.flowOptionFlag) {
                Object.assign(dataObj, await this.$refs.FlowOptionModal.getData())
              }
            }
          } else {
            //没有配置自定义表单，不需要调handleOk，直接提交
            ifDoHandleOk = false
          }
          //默认保存成功
          let resultSave = true
          //是否需要走handleOk
          if(ifDoHandleOk){
            //先走handleOk
            await this.$refs.modalForm.handleOk('check').catch(err=>{
              //保存数据出错
              resultSave=false
            })
            if(!resultSave){
              //保存数据出错，停止加载，返回
              this.confirmLoading = false
              return false
            }
          }
          //是否需要处理绩效数据
          if (checkPerformance) {
            await getAction(this.url.deleteRecord, { mainId: this.tableId }).then(async (res) => {
              //先删除以前采集/填报数据
              if (res.success) {
                //给流程中参数赋值，方便回调
                this.setDataValue(message,amount,yjjcText,approverText,tripleAndBig,dataObj)
                //调用弹出绩效处理弹窗方法，后续全权交由绩效弹窗组件回调处理
                this.checkPlanOrRemib()
              } else {
                this.$message.warn(res.message)
              }
            })
            //只要进了处理绩效，后续的方法就不在执行了
            this.confirmLoading = false
            return false
          }
          //最后都需要走提交方法
          if (this.$refs.modalForm.amount) {
            amount = this.$refs.modalForm.amount
          }

          //默认提交成功
          let resultFlag = true
          await this.commitFLow(message, amount, yjjcText, approverText, tripleAndBig, dataObj).catch(err=>{
            //提交出错
            resultFlag = false
          })
          if (!resultFlag) {
            //提交出错，停止加载，返回
            this.confirmLoading = false
            return false
          }
        }
        /** refactor end  ------vinjor-m */
        /** 以下代码未重构，不清楚做什么用的，    vinjor-m */

        // //驳回时访问流程里的internalUrl，旧版预算还钱用的，现在不用了
        // if (this.flag == '0' && this.internalUrl && this.internalUrl != '') {
        //   let url = this.internalUrl + this.tableId
        //   httpAction(url, {}, 'post').then(res => {
        //   })
        // }

      },
      /**
       * 封装后的流程流转方法（提交、驳回）
       * @author 于晓洋
       * @param message 审批备注
       * @param amount
       * @param yjjcText 研究决策
       * @param approverText
       * @param tripleAndBig
       * @param dataObj
       * @Date 2020-11-9日
       * --- modify  history ---
       * vinjor-m    2021-3-11    增加扩展性较好的对象参数 dataObj(不能是null)
       * vinjor-m   2021年7月8日  审批时，如果选择的预算改变了，则需要查询出新的项目负责人传递到工作流中
       */
      async commitFLow (message, amount, yjjcText, approverText, tripleAndBig, dataObj) {
        let that = this
        that.confirmLoading = true
        if (null == dataObj || '' == dataObj) {
          dataObj = {}
        }
        let proLeaderId = await this.getProLeader()
        if ('' != proLeaderId) {
          dataObj['proLeaderId'] = proLeaderId
        }
        //判断是否有直接结束流程的选项，如果有，则往流程中传入endTheProcess，工作流根据endTheProcess这个参数去走结束流程的分支
        if(this.endTheProcessFlag){
          dataObj['endTheProcess'] = this.endTheProcess ? 1 : 0
        }
        //判断是否有输入还款金额选项，如果有且选择了结束流程，则往流程中传入returnMoney
        if(this.ifShowReturnFlag && this.endTheProcess){
          dataObj['returnMoney'] = this.returnMoney
        }
        //2021.3.25 sunqaing 去除金额逗号
        amount = (amount + '').replace(/\,/g, '')
        await httpAction('/handle/task/complete/' + this.taskId + '/' + this.flag + '/' + message + '/' + amount + '/' + yjjcText + '/' + approverText + '/' + tripleAndBig, dataObj, 'post').then((res) => {
          if (res.success) {
            that.$emit('ok')
            that.$message.success(res.message)
            that.confirmLoading = false
            that.close()
            return Promise.resolve()
          } else {
            that.$message.warning(res.message)
            //如果操作失败删除采集/填报的数据
            getAction(this.url.deleteRecord,{mainId:this.tableId})
            that.confirmLoading = false
            return Promise.reject()
          }
        })
      },
      /**
       * @description 判断经济科目是否发生改变，如果改变了，则需要查询出新的 项目负责人
       * @author vinjor-m
       * @date 2021年7月8日
       */
      async getProLeader () {
        return new Promise(resolve => {
          let proLeaderId = ''
          //判断经济科目有没有发生改变
          if (undefined != this.$refs.modalForm.$refs.budgetinformationmodal) {
            let newInternalid = this.$refs.modalForm.$refs.budgetinformationmodal.newInternalid
            let oldInternalid = this.$refs.modalForm.$refs.budgetinformationmodal.oldInternalid
            if (newInternalid != oldInternalid) {
              //只要经济科目发生改变，重新查询项目负责人
              getAction(this.url.getProLeaderUrl, { subjectId: newInternalid }).then(result => {
                if (result.success) {
                  if (result.result && result.result != '') {
                    proLeaderId = result.result
                  }
                }
                return resolve(proLeaderId)
              }).catch(err=>{
                return resolve("")
              })
            } else {
              return resolve(proLeaderId)
            }
          } else {
            return resolve(proLeaderId)
          }
        })
      },
      /**流程分支配置,当配置了,走该方法,用于存到数据库 (保留)*/
      branchs (val) {
        if (this.processBranch != '' && this.processBranch != null) {
          let str = this.processBranch[0].dictCode1.split(',')
          let branch = {
            dataId: val,
            branchValue: str[0] + ',' + str[1]
          }
          this.branchList.push(branch)
          let jsonParam = {}
          if (this.processBranch) {
            jsonParam = this.processBranch
          }
          let finalItemArr = []
          for (let i = 0; i < jsonParam.length; i++) {
            let a = jsonParam[i].dictCode1.split(',')
            let objItem = {
              dataId: val,
              branchValue: a[0] + '.' + a[1]
            }
            finalItemArr.push(objItem)
          }
          postAction(this.url.addRelatiopn, finalItemArr).then(res => {
          })
        }
      }
    }
  }
</script>

<style lang="less" scoped>
  .danger {
    border-color: #e92600;
    color: #FFF;
    background-color: #e92600;
  }

  .danger:hover {
    border-color: #FF0000;
    background-color: #FF0000;
  }

  .account-settings-info-main {
    width: 100%;
    display: flex;
    height: 100%;
    overflow: auto;

    &.mobile {
      display: block;

      .account-settings-info-left {
        border-right: unset;
        border-bottom: 1px solid #e8e8e8;
        width: 100%;
        height: 50px;
        overflow-x: auto;
        overflow-y: scroll;
      }

      .account-settings-info-right {
        padding: 20px 40px;
        overflow-x: auto;
      }
    }

    .account-settings-info-left {
      border-right: 1px solid #e8e8e8;
      width: 160px;
    }

    .account-settings-info-right {
      flex: 1 1;
      padding: 8px 40px;
      overflow-x: auto;

      .account-settings-info-title {
        color: rgba(0, 0, 0, .85);
        font-size: 20px;
        font-weight: 500;
        line-height: 28px;
        margin-bottom: 12px;
      }

      .account-settings-info-view {
        padding-top: 12px;
      }
    }
  }

  .btn_none {
    .ant-modal-footer {
      display: none;
    }
  }
  .outer_box{
    /*width: 200px;*/
    /*height: 200px;*/
    position: fixed;
    width: 100%;
    height: 100%;
    left: 0px;
    top: 0px;
    background: rgba(0,0,0,.5);
    z-index: 50;
    text-align: center;
  }
  .outer_box>div{
    white-space: nowrap;
    display: inline-block;
  }
  .outer_box>div>img{
    width: auto;
    height: auto;
    position: absolute;
  }
</style>
<style scoped src="../packages/styles/index1.css">
</style>